home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / TS32 / TS32.ZIP / DIBCanvas.int < prev    next >
Text File  |  1996-03-21  |  4KB  |  104 lines

  1. unit DIBCanvas;
  2.  
  3. (***************************************************
  4. TDIBCanvas->TPersistent
  5.  
  6. A special canvas that works with DIB image memory.
  7. Optimized drawing routines replace GDI calls in the
  8. implementation of this canvas' methods.
  9.  
  10. Properties
  11.  
  12. Bits-
  13.   Pointer to the image memory.
  14. BrushColorIndex-
  15.   The color used during fill operations.
  16. ClipRect-
  17.   Returns the bounding rectangle of the canvas.
  18. Height-
  19.   The height in pixels of the drawing surface.
  20. Orientation-
  21.   Determines if the drawing surface is top-down or bottom-up.
  22. PenColorIndex-
  23.   The color index used for drawing operations.
  24. Pixels[x,y]-
  25.   Gets/sets pixels in the drawing surface.  It is YOUR responsibility
  26.   to perform boudns checking when accessing the pixels via this
  27.   property.
  28. PixelsClip[x,y]-
  29.   Access to the pixels with clipping.  Use this property if
  30.   you are not performing your own bounds checking when accessing
  31.   the pixels.
  32. Size-
  33.   The number of bytes used by the image.
  34. TransparentColor-
  35.   The color index that will serve as the transparent color when
  36.   a region of this canvas is copied onto another.
  37. Width-
  38.   The width in pixels of the drawing surface.
  39.  
  40. Events
  41.  
  42. Methods
  43.  
  44. CopyRect-
  45.   Copies a rectangular region from one DIBCanvas to another.
  46. FillRect-
  47.   Fill the rectangle with the current BrushColorIndex.
  48. LineTo-
  49.   Draws a line using the current PenColorIndex.
  50. MoveTo-
  51.   Moves the cursor to the specified location.
  52. Rectangle-
  53.   Draws a rectangle using the current PenColorIndex.
  54. ***************************************************)
  55.  
  56. interface
  57.  
  58. uses
  59.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grafix;
  60.  
  61. type
  62.   TDIBCanvas = class( TPersistent )
  63.   private
  64.      FBrushColorIndex: byte;
  65.      FData: pointer;
  66.      FHeight: integer;
  67.      FOrientation: TDIBOrientation;
  68.      FPenColorIndex: byte;
  69.      FTransColor: byte;
  70.      FWidth: integer;
  71.      parData: PByteArray;
  72.      nDummy: integer;
  73.   protected
  74.      ptCursor: TPoint;
  75.      procedure Assign( Source: TPersistent ); override;
  76.      procedure SetBits( p: pointer );
  77.      function GetPixels( x, y: integer ): byte;
  78.      procedure SetPixels( x, y: integer; b: byte );
  79.      function GetPixelsClip( x, y: integer ): byte;
  80.      procedure SetPixelsClip( x, y: integer; b: byte );
  81.      function GetSize: integer;
  82.      function GetClipRect: TRect;
  83.      procedure SetWidth( n: integer ); virtual;
  84.      procedure SetHeight( n: integer ); virtual;
  85.   public
  86.      constructor Create;
  87.      procedure CopyRect( Dest: TRect; Canvas: TDIBCanvas; Source: TRect );
  88.      procedure FillRect( rect: TRect );
  89.      procedure LineTo( x, y: integer );
  90.      procedure MoveTo( x, y: integer );
  91.      procedure Rectangle( X1, Y1, X2, Y2: integer );
  92.      property Bits: pointer read FData write SetBits;
  93.      property ClipRect: TRect read GetClipRect;
  94.      property Pixels[x, y: integer]: byte read GetPixels write SetPixels;
  95.      property PixelsClip[x, y: integer]: byte read GetPixelsClip write SetPixelsClip;
  96.   published
  97.      property BrushColorIndex: byte read FBrushColorIndex write FBrushColorIndex;
  98.      property Height: integer read FHeight write SetHeight;
  99.      property Orientation: TDIBOrientation read FOrientation write FOrientation;
  100.      property PenColorIndex: byte read FPenColorIndex write FPenColorIndex;
  101.      property TransparentColor: byte read FTransColor write FTransColor;
  102.      property Width: integer read FWidth write SetWidth;
  103.      property Size: integer read GetSize write nDummy stored FALSE;
  104.   end;